package com.example.exam.mapper;

import com.example.exam.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    @Insert("INSERT INTO user (user_name, password) VALUES " +
            "(#{userName}, #{password})")
    int insertUser(User user);


    @Update("UPDATE user SET user_name = #{userName}, password = #{password} WHERE id=#{id}")
    int updateUserById(User user);


    @Select("SELECT * FROM user WHERE  id =#{id} ")
    User selectUserById(Long id);

    @Select("SELECT * FROM user WHERE  user_name =#{username} ")
    User selectUserByUsername(String  username);



    @Delete("delete table user  where  id = #{id} ")
    int deleteUserById(Long id);
}
